import { OrgServiceApi, WorkflowServiceApi } from "./_workflow";
import { AxiosResponse } from "axios";
import { objectToUrlParams } from "/@/utils/common";
import service from "/@/utils/request";
import { SYSTEM_CONFIG } from "/@/config/system";

class WorkFlowConfigServiceApi extends WorkflowServiceApi {
  // 查看运行版本dialog表格数据
  getHistoryVersion(bean: any, params?: any): Promise<AxiosResponse<any>> {
    let url = this.baseUrl + "/getHistoryVersion";
    url += objectToUrlParams(params, true);
    return service.get(url, { params: { ...bean } });
  }
  // 发布/更新发布
  deployModel(bean: any, params?: any): Promise<AxiosResponse<any>> {
    let url = this.baseUrl + "/deployModel";
    url += objectToUrlParams(params, true);
    return service.post(url, bean);
  }
  // 复制流程
  copyData(bean: any, params?: any): Promise<AxiosResponse<any>> {
    let url = this.baseUrl + "/copyData";
    url += objectToUrlParams(params, true);
    return service.post(url, bean);
  }
  saveMasterDetail(bean: any, params?: any): Promise<AxiosResponse<any>> {
    let url = this.baseUrl + "/saveMasterDetail";
    url += objectToUrlParams(params, true);
    return service.post(url, bean);
  }
  createNewModel(bean: any, params?: any): Promise<AxiosResponse<any>> {
    let url = this.baseUrl + "/createNewModel";
    url += objectToUrlParams(params, true);
    return service.post(url, bean);
  }

}

export const ExportWorkFlowConfigServiceApi = new WorkFlowConfigServiceApi(
  '/WorkFlowConfigService'
)
class WorkFlowDesignServiceApi extends WorkflowServiceApi {
  viewModelXml(bean: any, params?: any): Promise<AxiosResponse<any>> {
    let url = this.baseUrl + "/viewModelXml";
    url += objectToUrlParams(params, true);
    return service.get(url, {
      params: { ...bean },
      responseType: "blob",
      timeout: SYSTEM_CONFIG.DOWNLOAD_FILE_TIMEOUT,
    });
  }
  importModelFromXml(bean: any, params?: any): Promise<AxiosResponse<any>> {
    let url = this.baseUrl + "/importModelFromXml";
    url += objectToUrlParams(params, true);
    return service.post(url, bean);
  }
}
export const ExportWorkFlowDesignServiceApi = new WorkFlowDesignServiceApi(
  '/WorkFlowDesignService'
)

class WorkFlowConfigDetailServiceApi extends WorkflowServiceApi { }
export const ExportWorkFlowConfigDetailServiceApi = new WorkFlowConfigDetailServiceApi(
  '/WorkFlowConfigDetailService'
)
